home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Eagles Nest BBS 8
/
Eagles_Nest_Mac_Collection_Disc_8.TOAST
/
Developer Tools⁄Additions
/
InsideBa1994
/
InsideBasic-94
/
IB 94
/
Banner
/
Banner.BAS
Wrap
BASIC Source File
|
1994-01-20
|
9KB
|
243 lines
' Banner Spanner
' Richard B. Bartlett
' © Copyright 1990, Bartlett, Bradley & Lucky
' All rights reserved
'_____________________________________________________________________________
' Configure Options for ZBasic 5.0x
' Default variable Type: Integer
' Optimize expressions as Integer: On
' Space Req. After Key Words: On
' All other options: Off
'_____________________________________________________________________________
WINDOW OFF
COORDINATE WINDOW
true = NOT false
ON BREAK GOSUB "Break"
ON DIALOG GOSUB "Dialog"
ON MENU GOSUB "Menu"
GOSUB "Startup"
DO
DIALOG ON: MENU ON
DIALOG OFF: MENU OFF
IF printNow THEN GOSUB "Print" : ' Print if flag is set
UNTIL done : ' Quit if flag is set
END
'_____________________________________________________________________________
"Dialog"
myEvent = DIALOG(0)
which = DIALOG(myEvent)
SELECT myEvent
CASE 1,6 : ' Click in button or Return pressed
printNow = true : ' Set flag indicating desire to print
CASE 5 : ' Window refresh needed
GOSUB "Refresh1" : ' Refresh main window
END SELECT
RETURN
'_____________________________________________________________________________
"Menu"
menuId = MENU(0)
itemId = MENU(1)
SELECT menuId
CASE 1 : ' File menu
SELECT itemId
CASE 1 : ' Page Setup
DEF PAGE
MENU
CASE 2 : ' Print
printNow = true : ' Set Print flag
CASE 4 : ' Quit
done = true : ' Set Quit Program flag
END SELECT
END SELECT
RETURN
'_____________________________________________________________________________
"Break"
abortPrint = true : ' Set Quit Printing flag
RETURN
'_____________________________________________________________________________
"Startup"
t = 3: l = 366: b = 31: r = 434 : ' Rectangle to frame button
DIM fAscent,fDecent,fWidth,fLeading : ' FontInfo record
plain = 0: bold = 1: italic = 2: underline = 4 :' Available
outline = 8: shadow = 16: condense = 32: extended = 64 :' text modes
MENU 1,0,1,"File"
MENU 1,1,1,"Page Setup…"
MENU 1,2,1,"P/Print…"
MENU 1,4,1,"Q/Quit"
DIALOG ON : ' Multifinder kluge to force our
DIALOG OFF : ' window to front position
WINDOW 1, "Banner Spanner",( 10,50)-(502,130),261
EDIT FIELD 1, "", ( 8,35)-(484, 70)
BUTTON 1,1,"Print", (370, 7)-(430, 27)
RETURN
'_____________________________________________________________________________
LONG FN Boxer : ' Draw a box around our Banner
top = rPageT
left = rPageL - (currentPage - 1) * pageWid + 20
bottom = rPageB
right = left + stringLen + 104
BOX left,top TO right,bottom
END FN
LONG FN MyText(num,siz,fac,mde) : ' Replaces ZBasic TEXT statement
CALL TEXTFONT(num) : ' to avoid extra page eject
CALL TEXTSIZE(siz) : ' from ImageWriter
CALL TEXTFACE(fac)
CALL TEXTMODE(mde)
END FN
'_____________________________________________________________________________
"Print"
printNow = false : ' Reset Print Now flag
banner$ = EDIT$(1) : ' Get the string to be printed
FLUSHEVENTS
LONG IF LEN(banner$) = 0 : ' If the string is empty, alert user
temp$ = "There is no text to print!"
CALL PARAMTEXT(temp$,"","","")
dummy = FN CAUTIONALERT(1,0)
MENU
RETURN
END IF
DEF LPRINT
LONG IF NOT PRCANCEL
CURSOR 4 : ' Use the Watch cursor
abortPrint = false : ' Clear CANCEL Printing flag
GOSUB "PrintRec" : ' Check out the Print Record
GOSUB "FontInfo" : ' Prepare to print the Banner
pages = stringLen / pageWid : ' Calculate pages needed for Banner
IF pages * pageWid < stringLen THEN pages = pages + 1 :' Round up if needed
startPage = iFstPage : ' Get 1st page to print
endPage = iLstPage : ' Get last page to print
IF startPage > 1 THEN POKE WORD PEEK LONG(PRHANDLE) + 62,1 :' Tell printer
: ' we are starting with the first page
LONG IF endPage = 9999 : ' If default value then
endPage = pages : ' print to last page
XELSE : ' otherwise
POKE WORD PEEK LONG(PRHANDLE) + 64,9999 : ' tell printer all pages
END IF
WINDOW 2,"printing",(100,100)-(412,200),4 : ' Printing progress window
FOR currentPage = startPage TO endPage : ' For each page to be printed
BREAK ON : ' Check for CANCEL printing
BREAK OFF
LONG IF abortPrint = false : ' If not CANCELed
LONG IF currentPage <= pages : ' If not past last page
GOSUB "Refresh2" : ' Update the Progress window
ROUTE 128 : ' Route output to printer
FN Boxer : ' Draw box around Banner
FN MyText(fNum,fHeight,face,1) : ' Set font,size,face & mode
CALL MOVETO(72 -(currentPage - 1) * pageWid,fAscent - fLeading)
: ' Offset Banner location
CALL DRAWSTRING(banner$) : ' Print the Banner
ROUTE 0 : ' Route output to screen
CLOSE LPRINT : ' Close the printer driver
END IF
END IF
NEXT
WINDOW CLOSE 2 : ' Close Printing Progress window
CURSOR 0 : ' Use arrow cursor
END IF
MENU
RETURN
'_____________________________________________________________________________
"Refresh1" : ' Fill in the Main window
TEXT 4,9,0,0 : ' 9 pt Monaco
PRINT %(60,20) "Please enter the text for your banner…"
PEN 3,3
CALL FRAMEROUNDRECT(t,16,16) : ' Frame the "Print" button
CALL PENNORMAL
RETURN
'_____________________________________________________________________________
"Refresh2" : ' Fill in the "Printing" window
TEXT 0,12,0,0 : ' 12 pt Chicago
PRINT @(2,1) "Printing page";currentPage;"of your banner… "
temp$ = "Press " + CHR$(17) + " and " + CHR$(34) + "." + CHR$(34)
temp$ = temp$ + " to CANCEL."
PRINT @(5,3) temp$ : ' Tell user how to cancel printing
RETURN
'_____________________________________________________________________________
"PrintRec"
pRec& = USR 3(PRHANDLE) : ' Lock handle to print record (TPrint)
rPageT = PEEK WORD(pRec& + 8) : ' Paper rectangle (printable area)
rPageL = PEEK WORD(pRec& + 10)
rPageB = PEEK WORD(pRec& + 12)
rPageR = PEEK WORD(pRec& + 14)
iFstPage = PEEK WORD(pRec& + 62) : ' First page to print (TPrJob)
iLstPage = PEEK WORD(pRec& + 64) : ' Last page to print
dummy& = USR 7(PRHANDLE) : ' Unlock print record
pageWid = rPageR - rPageL : ' Width of printable area
pageLen = rPageB - rPageT : ' Length of printable area
RETURN
'_____________________________________________________________________________
"FontInfo"
CALL GETFNUM("Times",fNum) : ' Find the font number of this font
fHeight = pageLen : ' Set font size to page height
face = outline + condense : ' Calculate font face desired
TEXT fNum,fHeight,face,1 : ' Use desired font temporarily
CALL GETFONTINFO(VARPTR(fAscent)) : ' Get needed font information
WHILE fAscent + fDecent > pageLen : ' While font is too large to fit page
fHeight = fHeight - 1 : ' Use font size 1 point smaller
TEXT ,fHeight : ' Reset desired font size
CALL GETFONTINFO(VARPTR(fAscent)) : ' Recheck font information
WEND
stringLen = FN STRINGWIDTH(banner$) + 72 : ' Get the string width and add some
TEXT 4,9,0,0 : ' Restore the original font
RETURN